package com.bzyd.cloud.rocketmq;

import com.alibaba.fastjson.JSON;
import com.bzyd.cloud.pojo.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * 短信发送服务
 * Created by Xianyue Dang on 2021/8/19
 */
@Slf4j
@Service("shopSmsService")
@RocketMQMessageListener(
        consumerGroup = "shop-user",//消费者组名
        topic = "order-topic",//消息主题，相当于分类
        consumeMode = ConsumeMode.CONCURRENTLY,//消费模式，指定是否顺序消费，CONCURRENTLY（同步，默认），ORDERLY（顺序）
        messageModel = MessageModel.CLUSTERING//消息模式，BROADCASTING（广播），CLUSTERING（集群，默认）
)
public class SmsService implements RocketMQListener<Order> {


    @Override
    public void onMessage(Order order) {
        log.info("接收到一个订单信息{}，接下来发送短信", JSON.toJSONString(order));
    }
}
